home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 24 / AACD 24.iso / AACD / Utilities / ttf2pt1PPC / src / byteorder.h < prev    next >
Text File  |  2000-04-19  |  790b  |  25 lines

  1. /*
  2.  * see COPYRIGHT
  3.  */
  4.  
  5. /*    This defines the macroes ntohs and ntohl, which convert short and long
  6.     ints from network order (used on 68000 chips, and in TrueType font
  7.     files) to whatever order your computer uses. #define _BIG_ENDIAN or not
  8.     to control which set of definitions apply. If you don't know, try both. If
  9.     you have a peculiar machine you're on your own.
  10. */
  11.  
  12. #if defined(_BIG_ENDIAN)
  13. #define    ntohl(x)    (x)
  14. #define    ntohs(x)    (x)
  15. #else
  16. #define ntohs(x) \
  17.     ((USHORT)((((USHORT)(x) & 0x00ff) << 8) | \
  18.               (((USHORT)(x) & 0xff00) >> 8))) 
  19. #define ntohl(x) \
  20.     ((ULONG)((((ULONG)(x) & 0x000000ffU) << 24) | \
  21.              (((ULONG)(x) & 0x0000ff00U) <<  8) | \
  22.              (((ULONG)(x) & 0x00ff0000U) >>  8) | \
  23.              (((ULONG)(x) & 0xff000000U) >> 24)))  
  24. #endif
  25.